<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h1>注册</h1>
    <!-- <form action="/register" method="post"> -->
    用户名：<input type="text" id="user"><br>
    密码：<input type="text" id="pass"><br>
    <span></span><br>
    <button>注册</button>
    <!-- </form> -->
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <script src="./ajax封装.js"></script>
    <script>
        $('button').click(async () => {
            //获取用户输入的数据
            let username = $('#user').val();
            let password = $('#pass').val();
            // console.log(username,password);

            //使用
            async function fn() {
                let [err, res] = await myajax({ type: 'post', url: '/register', data: { username, password }, });
                console.log(s);
                if(err){
                    res.send(err);
                    return;
                }

                if(res.code == 200){
                    location.href = '2.login.html';
                }else{
                    00
                }
            }
            fn();

        })
    </script>
</body>

</html>